<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>书籍列表1</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.2/dist/semantic.min.css">
    <link rel="stylesheet" href="../static/css/animate.css" th:href="@{/css/animate.css}">
    <link rel="stylesheet" href="../static/css/me.css" th:href="@{/css/me.css}">
</head>
<body>

<style>

    p {
        text-align: center;
    }

    body {
        font-family: Arial, sans-serif;
        margin: 0;
        padding: 0;
    }

    header {
        background-color: #f8f9fa;
        padding: 20px;
        text-align: center;
    }

    .product-container {
        display: flex;
        justify-content: space-between;
        padding: 20px;
    }

    .product-column {
        flex: 1;
        margin-right: 20px;
    }

    .product-column:last-child {
        margin-right: 0;
    }

    .product-item {
        margin-bottom: 20px;
        border: 1px solid #ddd;
        border-radius: 5px;
        padding: 10px;
        text-align: center;
    }

    .product-item img {
        width: 100%;
        height: auto;
        display: block;
        margin-bottom: 10px;
    }

    .product-item h3 {
        font-size: 16px;
        margin: 0;
    }

    .product-item p {
        font-size: 14px;
        margin: 5px 0;
    }

    footer {
        background-color: #f8f9fa;
        padding: 20px;
        text-align: center;
        position: fixed;
        bottom: 0;
        width: 100%;
    }
    .book-container {
        width: 320px; /* 设置书籍容器的宽度 */
        height: auto; /* 或者您可以设置固定的高度，如果您希望所有书籍容器具有相同的高度 */
        margin: 10px; /* 可选：设置书籍容器之间的间距 */
    }

    .book-container img {
        width: 100%; /* 图像宽度占满书籍容器 */
        height: 350px; /* 图像高度自适应 */
    }

</style>
<style>
    .vip{
        background-image: url("../image/vip.png");
        width: 20px;
        height: 20px;
        display: inline-block;
        vertical-align: middle;
        background-size: 100%;
    }
</style>
    <!--导航-->
    <!--inverted:反色、attached:没有圆角，依附在上面:m-padded-tb-mini:m自己定义,padded,上下之间内部间隔,tb上下,mini小点-->
    <!--m-shadow-small:自定义导航阴影-->
    <!--导航-->
    <nav class="ui m-bg attached segment m-padded-tb-mini m-shadow-small" >
        <div class="ui container">
            <div class="ui secondary stackable menu">
                <h2 class="ui purple header item">书籍列表</h2>
                <a href="#" th:href="@{/index}" class="m-item item m-mobile-hide m-black"><i class=" user secret icon"></i>首页</a>
                <a href="#" th:href="@{/books}" class="active m-item item m-mobile-hide m-black"><i class="user secret icon"></i>图书信息</a>
                <a href="#" th:href="@{/goodBooks}" class="m-item item m-mobile-hide m-black"><i class="user secret icon"></i>推荐好书</a>
                <a href="#" th:href="@{/borrow}" class="m-item item m-mobile-hide m-black"><i class="users secret icon"></i>我的借阅</a>
              <a href="#" th:href="@{/alter}" class="m-item item m-mobile-hide m-black"><i class="users secret icon"></i>个人中心</a>
                <div class="right m-item m-mobile-hide menu">
                    <div class="ui dropdown  item">
                        <div class="text">
                            <i class="user plus icon " style="width: 20px;height: 20px"></i>
                            <i th:if="${userMessage.getVip()!=0}" class="vip" style="width: 20px;height: 20px"></i>
                            <label th:text="${userMessage.getStuname()}"></label>
                        </div>
                        <i class="dropdown icon"></i>
                        <div class="menu">
                            <a href="#" th:href="@{/alter}" class="item">修改信息</a>
                            <a href="#" th:href="@{/logouts}" class="item">注销</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show">
            <i class="sidebar icon"></i>
        </a>
    </nav>

    <!--中间内容-->
    <div  class="m-container-small m-padded-tb-big animated zoomIn">
        <div class="ui container">
            <div class="ui success message" th:unless="${#strings.isEmpty(message)}">
                <i class="close icon"></i>
                <div class="header">提示：</div>
                <p th:text="${message}">恭喜，借阅成功！</p>
            </div>

            <div  class="ui secondary segment form">
                <input type="hidden" name="pageNum" >
                <div class="inline fields">
                    <div class="field">
                        <input type="text" id="bookId" name="bookId" placeholder="书号">
                    </div>
                    <div class="field">
                        <input type="text" id="name" name="name" placeholder="书名">
                    </div>
                    <div class="field">
                        <button  type="submit" id="search-btn" class="ui purple basic button"><i class="search icon"></i>搜索</button>
                    </div>
                </div>
            </div>
            <div id="table-container">
                <div class="product-container" th:fragment="allBook">


                    <div class="product-item" >

                        <table>
                            <tr th:each="books : ${groupedBooks}">
                                <td th:each="book : ${books}">
                                    <div class="book-container">
                                    <a th:href="@{/bookXQ?(bookId=${book.getId()})}">
                                         <img th:src="${book.img}" />
                                          <h3 th:text="${book.name}"></h3>
                                          <div>价格：<span th:text="${book.getPrice()}"></span></div>
                                        <div>可借数量：<span th:text="${book.getCount()}"></span></div>
                                          <div>isbn：<span th:text="${book.getIsbn()}"></span></div>
                                    </a>
                                          <a th:href="@{/books/{bookId}/borrow(bookId=${book.getId()})}" onclick="return confirm('您确定要借阅这本书吗？')" class="ui purple basic button" ><h5>借阅</h5>
                                          </a>
                                    </div>
                                </td>
                            </tr>
                        </table>


                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <br>
    <br>
    <!--底部footer-->
    <footer th:fragment="footer" class="ui m-bg animated fadeInUp inverted vertical segment m-padded-tb-massive">
        <div class="ui center aligned container">
            <div class="ui inverted divided stackable grid">
                <div class="three wide column">
                    <div class="ui inverted link list">
                    </div>
                </div>
                <div class="three wide column">
                    <div id="newblog-container">
                    </div>
                </div>
                <div class="three wide column">

                </div>
            </div>
            <div class="ui inverted m-black section divider"></div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
    <script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
    <script src="../static/js/colourBar.js" th:src="@{/js/colourBar.js}" tppabs="../static/js/colourBar.js"></script>

    <script th:inline="javascript">
        var message = [[${message}]];
        if(message != null){
            alert(message)
        }

        $('.menu.toggle').click(function () {
            $('.m-item').toggleClass('m-mobile-hide');
        });

        $('.ui.dropdown').dropdown({
            on : 'hover'
        });

        //消息提示关闭初始化
        $('.message .close')
            .on('click', function () {
                $(this)
                    .closest('.message')
                    .transition('fade');
            });

        function page(obj) {
            $("[name='pageNum']").val($(obj).data("page"));//获取page隐含域赋值
            loaddata();
        }

        // 点击事件；page清零，搜索不会查询某一页
        $("#search-btn").click(function () {
            // $("[name='pageNum']").val(0);
            loaddata();
        });

        // 点击事件；page清零，搜索不会查询某一页
        $("#more").click(function () {
            // $("[name='pageNum']").val(0);
            loaddata();
        });

        //用来请求发送数据
        function loaddata() {
            console.log("newBook-loaddata")
            $("#table-container").load(/*[[@{/books/search}]]*/"/goodBooks1/search",{
                bookId : $("[name='bookId']").val(),
                name : $("[name='name']").val(),
                pageNum : $("[name='pageNum']").val()
            });
        }

    </script>
    <script src="../static/js/colourBar.js" th:src="@{/js/colourBar.js}" tppabs="../static/js/colourBar.js"></script>


</body>
</html>
